Skip to content

Keep plan review cards in document flow - #249

Open
LarryHu0217 wants to merge 3 commits into
johannesjo:mainfrom
LarryHu0217:codex/plan-review-comment-flow-214
Open

Keep plan review cards in document flow#249
LarryHu0217 wants to merge 3 commits into
johannesjo:mainfrom
LarryHu0217:codex/plan-review-comment-flow-214

Conversation

@LarryHu0217

@LarryHu0217 LarryHu0217 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • mount the pending input, review comments, and ask-code cards in flow slots after the selected plan block
  • preserve selection highlighting and sidebar scroll targeting while cleaning up slots on dismiss and unmount
  • anchor multi-block selections after their final block and handle list/table markup safely
  • start a fresh review session when the task, worktree, or plan content changes so stale slots and comments are not reused

Addresses the plan-review inline comment overlap item in #214.

Validation

  • npm test -- src/components/plan-review-flow.test.ts (3 passed)
  • npx vitest run src (65 files passed, 792 tests passed)
  • npm run check
  • npm run check:static
  • npm run build:frontend

@johannesjo johannesjo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found two behavior regressions in the new flow-slot interaction, both reproduced in Chromium against the DOM structure introduced here:

  1. A multi-block selection that crosses an existing flow slot includes the card review/answer text in Selection.toString(), so subsequent review or Ask prompts can quote UI content as plan content.
  2. Highlight geometry is a one-time snapshot even though preceding slots now reflow, resize, and disappear, so the persisted highlight can drift away from the selected text.

The added tests only assert source strings and CSS, so they do not exercise either DOM behavior.

There is also a current integration blocker: main advanced to 1aabea4 and the PR now conflicts in PlanViewerDialog.tsx around the scroll-target guard (if (!target?.id) return). Please update the branch and preserve that guard while resolving the conflict.

function handleMouseUp(event: MouseEvent) {
if (!contentRef) return;
const eventTarget = event.target;
if (eventTarget instanceof Element && eventTarget.closest(PLAN_REVIEW_FLOW_SLOT_SELECTOR)) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only rejects a selection whose mouse-up endpoint is inside a slot. Because the portal is physically mounted inside contentRef, a range that crosses an existing slot but ends on later plan text still passes this guard. I reproduced that range in Chromium: Selection.toString() included Review · Goal Previous feedback between the two plan paragraphs. getPlanSelection then stores that UI text as selectedText, polluting the next review or Ask prompt. Please exclude [data-plan-review-flow-slot] descendants from selection extraction/highlighting and add a DOM-level regression test for a range spanning an existing card.

Comment thread src/components/PlanViewerDialog.tsx Outdated
const { y, rects } = captureSelectionGeometry();
setSelectionY(y);
setHighlightRects(rects);
setHighlightRects(captureSelectionGeometry());

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These rectangles are captured before the previous pending slot is removed on the next line. If that slot is above the new selection, its removal immediately shifts the selected text while the absolute overlay keeps the old coordinates; an 80px test slot produced 96px of drift in Chromium. An earlier Ask card expanding while streaming, or a sidebar dismissal, causes the same stale geometry. Please make the highlight track layout changes (for example by retaining the range and recalculating), and at minimum remove the prior pending slot before capturing the new geometry.

@LarryHu0217
LarryHu0217 force-pushed the codex/plan-review-comment-flow-214 branch from 1409bbc to 65fb8d7 Compare August 4, 2026 14:09
@LarryHu0217

Copy link
Copy Markdown
Contributor Author

Addressed all requested changes in 65fb8d7.

  • Selection extraction now clones the selected ranges and removes [data-plan-review-flow-slot] descendants, so card UI text cannot enter Review or Ask prompts.
  • Highlights retain source ranges and recalculate through ResizeObserver; the previous pending slot is removed before new geometry is measured.
  • Added real DOM regression tests for a selection spanning an existing card and for highlight updates after reflow.
  • Rebased onto current main and preserved the if (!target?.id) return scroll guard.

Validation: full test suite 1,755 passed/23 skipped plus 11 client tests; type checks, static checks, and frontend build pass.

@LarryHu0217
LarryHu0217 requested a review from johannesjo August 4, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants